885567
@@ -373,8 +373,16 @@
public class Scan extends Query {
    * next closest row after the specified row.
    * @param startRow row to start scanner at or after
    * @return this
+   * @throws IllegalArgumentException if startRow does not meet criteria
+   * for a row key (when length exceeds {@link HConstants#MAX_ROW_LENGTH})
    */
   public Scan setStartRow(byte [] startRow) {
+    if (Bytes.len(startRow) > HConstants.MAX_ROW_LENGTH) {
+      throw new IllegalArgumentException(
+        "startRow's length must be less than or equal to " +
+        HConstants.MAX_ROW_LENGTH + " to meet the criteria" +
+        " for a row key.");
+    }
     this.startRow = startRow;
     return this;
   }
@@ -389,8 +397,16 @@
public class Scan extends Query {
    * use {@link #setRowPrefixFilter(byte[])}.
    * The 'trailing 0' will not yield the desired result.</p>
    * @return this
+   * @throws IllegalArgumentException if stopRow does not meet criteria
+   * for a row key (when length exceeds {@link HConstants#MAX_ROW_LENGTH})
    */
   public Scan setStopRow(byte [] stopRow) {
+    if (Bytes.len(stopRow) > HConstants.MAX_ROW_LENGTH) {
+      throw new IllegalArgumentException(
+        "stopRow's length must be less than or equal to " +
+        HConstants.MAX_ROW_LENGTH + " to meet the criteria" +
+        " for a row key.");
+    }
     this.stopRow = stopRow;
     return this;
   }
